<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\BaseController;
use App\Models\Config;
use Illuminate\Http\Request;

class ConfigController extends BaseController
{
    protected $model = Config::class;

   public function store(Request $request) {
        $this->validate($request, [
            'value' => 'required',
            'key' => 'required',
        ]);
        $key = $request->input('key');
        $value = $request->input('value');
        if ($key == 'COMPANY_INFO') {
            Config::where('key', 'COMPANY_INFO')->update([
                'value' => $value
            ]);
        }
        return $this->success([]);
   }

   public function companyInfo() {
       $value = Config::where('key', 'COMPANY_INFO')->value('value');
       $arr = json_decode($value, true);
       return $this->success($arr);
   }

}

